﻿using ConsoleTools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace NimLearning
{
    public class NimLearningGame
    {
        public void Start()
        {
            switch (SelectMainMenu())
            {
                case 1:
                    HumanGame();
                    break;
                default:
                    AIGame(SelectNumGames());
                    break;
            }
        }

        public void HumanGame()
        {
            NewGame(new HumanPlayer(), new AIPlayer(), null);
        }

        public void AIGame(int count = 1)
        {
            for (int i = 0; i < count; i++)
            {
                NewGame(new AIPlayer(), new AIPlayer(), null);
            }
        }

        public void NewGame(Player first, Player second, GameState game)
        {
            NimGame nimGame = new NimGame(first, second, game);            
        }

        private int SelectMainMenu()
        {
            ConsoleIO.PrintLine("Choose an option: ");
            ConsoleIO.PrintLine("1. Player vs. AI");
            ConsoleIO.PrintLine("2. AI vs. AI");
            return ConsoleIO.GetInt("Choose an option: ", 1, 2);
        }

        private int SelectNumGames()
        {
            return ConsoleIO.GetInt("How many games to play: ", 1);
        }
    }
}
